<?php

namespace App\Http\Controllers;

use App\Services\ImageMessageService;
use App\Services\TextMessageHandler;
use App\Services\TextMessageService;
use EasyWeChat\Factory;
use EasyWeChat\Kernel\Messages\Message;

class WechatController extends Controller
{
    /**
     * Create a new controller instance.
     *
     * @return void
     */
    protected $wechat,$param;
    public function __construct()
    {
        $config = [
            'app_id' => 'wx702de6ba60e49e91',
            'secret' => 'b938fbbec4a2124284212d0dd5010088',
            'token' => 'ech0helloword111',
            'response_type' => 'array',
            'aes_key' => 'vtMfCcleArhbMmv8OGudWSvlgSKH4DnPhCwdfFTEijV'
        ];

        $this->wechat = Factory::officialAccount($config);

    }

    protected $msg,$action;
    public function server()
    {

        $this->wechat->server->push(TextMessageService::class, Message::TEXT); // 文本消息
        $this->wechat->server->push(ImageMessageService::class, Message::IMAGE); // 图片消息
        return $this->wechat->server->serve();
    }






    //
}
